CFLAGS=-g -Wall
CC=gcc

OBJECTS= test.o sha1.o parse_metafile.o bitfield.o log.o peer.o

bitc: $(OBJECTS)
	$(CC) $(CFLAGS) $^ -o $@

test.o: test.c parse_metafile.h bitfield.h dbg.h
	$(CC) $(CFLAGS) -c test.c

parse_metafile.o: parse_metafile.c parse_metafile.h dbg.h
	$(CC) $(CFLAGS) -c parse_metafile.c

sha1.o: sha1.c sha1.h
	$(CC) $(CFLAGS) -c sha1.c

bitfield.o: bitfield.c bitfield.h dbg.h
	$(CC) $(CFLAGS) -c bitfield.c

log.o: log.c log.h
	$(CC) $(CFLAGS) -c log.c

# signal_hander.o: signal_hander.c signal_hander.h
	# $(CC) $(CFLAGS) -c signal_hander.c

peer.o: peer.c peer.h
	$(CC) $(CFLAGS) -c peer.c

clean:
	rm -rf *.o
	rm -rf *.gch

test:
	./bitc test.torrent
